<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: ActiveSupport::Testing::Profiler</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">ActiveSupport::Testing::Profiler</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/vendor/rails/activesupport/lib/active_support/testing/performance_rb.html">
                vendor/rails/activesupport/lib/active_support/testing/performance.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="Performer.html">
                Performer
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000447">new</a>&nbsp;&nbsp;
      <a href="#M000451">output_filename</a>&nbsp;&nbsp;
      <a href="#M000450">record</a>&nbsp;&nbsp;
      <a href="#M000449">report</a>&nbsp;&nbsp;
      <a href="#M000448">run</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000447" class="method-detail">
        <a name="M000447"></a>

        <div class="method-heading">
          <a href="#M000447" class="method-signature">
          <span class="method-name">new</span><span class="method-args">(*args)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000447-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000447-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/testing/performance.rb, line 167</span>
167:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
168:           <span class="ruby-keyword kw">super</span>
169:           <span class="ruby-ivar">@supported</span> = <span class="ruby-ivar">@metric</span>.<span class="ruby-identifier">measure_mode</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">false</span>
170:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000450" class="method-detail">
        <a name="M000450"></a>

        <div class="method-heading">
          <a href="#M000450" class="method-signature">
          <span class="method-name">record</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000450-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000450-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/testing/performance.rb, line 191</span>
191:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">record</span>
192:           <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@supported</span>
193: 
194:           <span class="ruby-identifier">klasses</span> = <span class="ruby-identifier">profile_options</span>[<span class="ruby-identifier">:formats</span>].<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">const_get</span>(<span class="ruby-node">&quot;#{f.to_s.camelize}Printer&quot;</span>) }.<span class="ruby-identifier">compact</span>
195: 
196:           <span class="ruby-identifier">klasses</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">klass</span><span class="ruby-operator">|</span>
197:             <span class="ruby-identifier">fname</span> = <span class="ruby-identifier">output_filename</span>(<span class="ruby-identifier">klass</span>)
198:             <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir_p</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-identifier">fname</span>))
199:             <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">fname</span>, <span class="ruby-value str">'wb'</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span>
200:               <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@data</span>).<span class="ruby-identifier">print</span>(<span class="ruby-identifier">file</span>, <span class="ruby-identifier">profile_options</span>.<span class="ruby-identifier">slice</span>(<span class="ruby-identifier">:min_percent</span>))
201:             <span class="ruby-keyword kw">end</span>
202:           <span class="ruby-keyword kw">end</span>
203:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000449" class="method-detail">
        <a name="M000449"></a>

        <div class="method-heading">
          <a href="#M000449" class="method-signature">
          <span class="method-name">report</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000449-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000449-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/testing/performance.rb, line 183</span>
183:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">report</span>
184:           <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@supported</span>
185:             <span class="ruby-keyword kw">super</span>
186:           <span class="ruby-keyword kw">else</span>
187:             <span class="ruby-value str">'%20s: unsupported'</span> <span class="ruby-operator">%</span> <span class="ruby-ivar">@metric</span>.<span class="ruby-identifier">name</span>
188:           <span class="ruby-keyword kw">end</span>
189:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000448" class="method-detail">
        <a name="M000448"></a>

        <div class="method-heading">
          <a href="#M000448" class="method-signature">
          <span class="method-name">run</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000448-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000448-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/testing/performance.rb, line 172</span>
172:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>
173:           <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@supported</span>
174: 
175:           <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">measure_mode</span> = <span class="ruby-ivar">@metric</span>.<span class="ruby-identifier">measure_mode</span>
176:           <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">start</span>
177:           <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">pause</span>
178:           <span class="ruby-identifier">profile_options</span>[<span class="ruby-identifier">:runs</span>].<span class="ruby-identifier">to_i</span>.<span class="ruby-identifier">times</span> { <span class="ruby-identifier">run_test</span>(<span class="ruby-ivar">@metric</span>, <span class="ruby-identifier">:profile</span>) }
179:           <span class="ruby-ivar">@data</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
180:           <span class="ruby-ivar">@total</span> = <span class="ruby-ivar">@data</span>.<span class="ruby-identifier">threads</span>.<span class="ruby-identifier">values</span>.<span class="ruby-identifier">sum</span>(<span class="ruby-value">0</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">method_infos</span><span class="ruby-operator">|</span> <span class="ruby-identifier">method_infos</span>.<span class="ruby-identifier">sort</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">total_time</span> }
181:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Protected Instance methods</h3>

      <div id="method-M000451" class="method-detail">
        <a name="M000451"></a>

        <div class="method-heading">
          <a href="#M000451" class="method-signature">
          <span class="method-name">output_filename</span><span class="method-args">(printer_class)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000451-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000451-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/testing/performance.rb, line 206</span>
206:           <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">output_filename</span>(<span class="ruby-identifier">printer_class</span>)
207:             <span class="ruby-identifier">suffix</span> =
208:               <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">printer_class</span>.<span class="ruby-identifier">name</span>.<span class="ruby-identifier">demodulize</span>
209:                 <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'FlatPrinter'</span>; <span class="ruby-value str">'flat.txt'</span>
210:                 <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'GraphPrinter'</span>; <span class="ruby-value str">'graph.txt'</span>
211:                 <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'GraphHtmlPrinter'</span>; <span class="ruby-value str">'graph.html'</span>
212:                 <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'CallTreePrinter'</span>; <span class="ruby-value str">'tree.txt'</span>
213:                 <span class="ruby-keyword kw">else</span> <span class="ruby-identifier">printer_class</span>.<span class="ruby-identifier">name</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp re">/Printer$/</span>, <span class="ruby-value str">''</span>).<span class="ruby-identifier">underscore</span>
214:               <span class="ruby-keyword kw">end</span>
215: 
216:             <span class="ruby-node">&quot;#{super()}_#{suffix}&quot;</span>
217:           <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>